package io;

import java.io.*;

/**
@Auther: MFM
@Date: 2021/8/6 - 08 - 06 - 15:03 
@version: 1.0
*/

public class Demo {
    private static class Student implements Serializable {
        private static final long UID = 1L;
        private String name;
        private int age;

        public Student(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public Student() {
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }

    public static void objectStream() throws Exception{
        ObjectOutputStream oops = new ObjectOutputStream(new FileOutputStream("./file/aa/aa/acb.txt"));
        Student student = new Student("zhangsan",18);
        oops.writeObject(student);
        oops.close();
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("./file/aa/aa/acb.txt"));
        Student o = (Student) ois.readObject();
        System.out.println(o.getName()+"==="+o.getAge());
    }

    public static void main(String[] args) throws Exception{
        objectStream();
    }

}
